/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Wizard.java
 *
 * Created on 01/08/2011, 16:04:25
 */
package fallen.deck.front_end;

import fallen.deck.Drecker;
import fallen.deck.entity.Card;
import fallen.deck.entity.Deck;
import fallen.deck.entity.Pathway;
import fallen.deck.hibernate.Queries;
import java.awt.CardLayout;
import java.util.List;
import javax.swing.JOptionPane;

/**
 *
 * @author Carlos S. Moreno <CarlosS.Moreno@gmail.com>
 */
public class Wizard extends javax.swing.JDialog {

    int page = 0;
    Pathway pathway = null;
    List demons = null;
    Card demon = null;

    /** Creates new form Wizard */
    public Wizard() {
        initComponents();
        txtDeckName.setSelectionStart(0);
        txtDeckName.setSelectionEnd(txtDeckName.getText().length());
        txtDeckName.requestFocus();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupSenda = new javax.swing.ButtonGroup();
        buttonGroupExpansion = new javax.swing.ButtonGroup();
        buttonGroupDemon = new javax.swing.ButtonGroup();
        wizardPanels = new javax.swing.JPanel();
        panelWelcome = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btnStart = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtaWelcome = new javax.swing.JTextArea();
        txtDeckName = new javax.swing.JTextField();
        lblDeckName = new javax.swing.JLabel();
        lblStart = new javax.swing.JLabel();
        panelSenda = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        tbtnCaos = new javax.swing.JToggleButton();
        tbtnLocura = new javax.swing.JToggleButton();
        tbtnMuerte = new javax.swing.JToggleButton();
        tbtnPoder = new javax.swing.JToggleButton();
        jLabel13 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        btnBack1 = new javax.swing.JButton();
        btnNext1 = new javax.swing.JButton();
        btnCancel1 = new javax.swing.JButton();
        scrollPathway = new javax.swing.JScrollPane();
        txtaPathway = new javax.swing.JTextArea();
        panelExpansion = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        tbtnDESPERTAR = new javax.swing.JToggleButton();
        tbtnINSANIA = new javax.swing.JToggleButton();
        jLabel14 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        btnBack2 = new javax.swing.JButton();
        btnNext2 = new javax.swing.JButton();
        btnCancel2 = new javax.swing.JButton();
        panelDemon = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        btnBack3 = new javax.swing.JButton();
        btnFinish = new javax.swing.JButton();
        btnCancel3 = new javax.swing.JButton();
        btnDemon1 = new javax.swing.JToggleButton();
        btnDemon2 = new javax.swing.JToggleButton();
        btnDemon3 = new javax.swing.JToggleButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtaDemon = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Asistente de Creación de Mazos");
        setModal(true);
        setResizable(false);

        wizardPanels.setLayout(new java.awt.CardLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/wizard_images/wizard_page1.jpg"))); // NOI18N

        btnStart.setMnemonic('s');
        btnStart.setText("Comenzar!");
        btnStart.setToolTipText("Paso Siguiente");
        btnStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStartActionPerformed(evt);
            }
        });

        btnCancel.setMnemonic('c');
        btnCancel.setText("Cancelar");
        btnCancel.setToolTipText("Cancelar Asistente");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        txtaWelcome.setColumns(20);
        txtaWelcome.setEditable(false);
        txtaWelcome.setLineWrap(true);
        txtaWelcome.setRows(5);
        txtaWelcome.setText("Bienvenido a \"Drecker, el creador de mazos\".\n\nEste asistente te guiará para armar un mazo de INFERNO desde cero.\n\nCada mazo puede tener solo una carta de Demonio, y la senda de este es la que define gran parte de las cartas que podrás incluir, ya que solo podrás usar aquellas que tengan la misma senda que tu Demonio, y cartas blancas (neutrales).\n\nLo primero, es darle un nombre a tu nuevo mazo, de este modo podrás diferenciarlo, y no se me mezclará con los demás.\n\nLo siguiente es elegir una senda. Mas adelante podras ver una breve descripción de cada una de ellas.\n\nA esto le sigue elegir tu expansión de cartas favorita. Cada expansión tiene sus Demonios, de modo que una ves que tengas decidida tu senda y expansión, tendras para elegir entre 3 Demonios. Recuerda que, sin importar la expansion en que haya salido tu demonio, puedes mezclar expansiones en las cartas de tu mazo.\n\nElige con cudiado, idea tu estrategia, selecciona las mejores cartas, y crea el mazo mas poderoso... recuerda, el destino del mundo esta en juego.");
        txtaWelcome.setWrapStyleWord(true);
        txtaWelcome.setCaretPosition(1);
        jScrollPane2.setViewportView(txtaWelcome);

        txtDeckName.setText("Nuevo Mazo");

        lblDeckName.setText("Nombre del Mazo:");

        lblStart.setText("Ingresa el nombre del nuevo mazo para comenzar.");

        javax.swing.GroupLayout panelWelcomeLayout = new javax.swing.GroupLayout(panelWelcome);
        panelWelcome.setLayout(panelWelcomeLayout);
        panelWelcomeLayout.setHorizontalGroup(
            panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelWelcomeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelWelcomeLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lblStart, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelWelcomeLayout.createSequentialGroup()
                                .addComponent(lblDeckName)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE))
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelWelcomeLayout.createSequentialGroup()
                        .addComponent(btnStart)
                        .addGap(18, 18, 18)
                        .addComponent(btnCancel))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelWelcomeLayout.setVerticalGroup(
            panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelWelcomeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelWelcomeLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblStart)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblDeckName))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancel)
                    .addComponent(btnStart))
                .addContainerGap())
        );

        wizardPanels.add(panelWelcome, "card2");

        jLabel10.setText("Selecciona una senda para tu mazo.");

        buttonGroupSenda.add(tbtnCaos);
        tbtnCaos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Caos_BN_48.png"))); // NOI18N
        tbtnCaos.setToolTipText("Senda Caos");
        tbtnCaos.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Caos_48.png"))); // NOI18N
        tbtnCaos.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Caos_48.png"))); // NOI18N
        tbtnCaos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbtnCaosActionPerformed(evt);
            }
        });

        buttonGroupSenda.add(tbtnLocura);
        tbtnLocura.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Locura_BN_48.png"))); // NOI18N
        tbtnLocura.setToolTipText("Senda Locura");
        tbtnLocura.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Locura_48.png"))); // NOI18N
        tbtnLocura.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Locura_48.png"))); // NOI18N
        tbtnLocura.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbtnLocuraActionPerformed(evt);
            }
        });

        buttonGroupSenda.add(tbtnMuerte);
        tbtnMuerte.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Muerte_BN_48.png"))); // NOI18N
        tbtnMuerte.setToolTipText("Senda Muerte");
        tbtnMuerte.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Muerte_48.png"))); // NOI18N
        tbtnMuerte.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Muerte_48.png"))); // NOI18N
        tbtnMuerte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbtnMuerteActionPerformed(evt);
            }
        });

        buttonGroupSenda.add(tbtnPoder);
        tbtnPoder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Poder_BN_48.png"))); // NOI18N
        tbtnPoder.setToolTipText("Senda Poder");
        tbtnPoder.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Poder_48.png"))); // NOI18N
        tbtnPoder.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/48/Poder_48.png"))); // NOI18N
        tbtnPoder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbtnPoderActionPerformed(evt);
            }
        });

        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/wizard_images/wizard_page2.jpg"))); // NOI18N

        btnBack1.setMnemonic('a');
        btnBack1.setText("<< Anterior");
        btnBack1.setToolTipText("Paso Anterior");
        btnBack1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBack1ActionPerformed(evt);
            }
        });

        btnNext1.setMnemonic('s');
        btnNext1.setText("Siguiente >>");
        btnNext1.setToolTipText("Paso Siguiente");
        btnNext1.setEnabled(false);
        btnNext1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNext1ActionPerformed(evt);
            }
        });

        btnCancel1.setMnemonic('c');
        btnCancel1.setText("Cancelar");
        btnCancel1.setToolTipText("Cancelar Asistente");
        btnCancel1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancel1ActionPerformed(evt);
            }
        });

        txtaPathway.setColumns(20);
        txtaPathway.setEditable(false);
        txtaPathway.setLineWrap(true);
        txtaPathway.setRows(5);
        txtaPathway.setWrapStyleWord(true);
        scrollPathway.setViewportView(txtaPathway);

        javax.swing.GroupLayout panelSendaLayout = new javax.swing.GroupLayout(panelSenda);
        panelSenda.setLayout(panelSendaLayout);
        panelSendaLayout.setHorizontalGroup(
            panelSendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSendaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelSendaLayout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addGroup(panelSendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelSendaLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10))
                            .addGroup(panelSendaLayout.createSequentialGroup()
                                .addGap(105, 105, 105)
                                .addComponent(tbtnCaos)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tbtnLocura)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tbtnMuerte)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tbtnPoder))
                            .addGroup(panelSendaLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(scrollPathway, javax.swing.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelSendaLayout.createSequentialGroup()
                        .addComponent(btnBack1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnNext1)
                        .addGap(18, 18, 18)
                        .addComponent(btnCancel1))
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelSendaLayout.setVerticalGroup(
            panelSendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSendaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addGroup(panelSendaLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelSendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbtnCaos)
                            .addComponent(tbtnPoder)
                            .addComponent(tbtnMuerte)
                            .addComponent(tbtnLocura))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(scrollPathway, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelSendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancel1)
                    .addComponent(btnNext1)
                    .addComponent(btnBack1))
                .addContainerGap())
        );

        wizardPanels.add(panelSenda, "card3");

        panelExpansion.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                panelExpansionFocusGained(evt);
            }
        });

        jLabel11.setText("Selecciona la expansión que mas te guste.");

        buttonGroupExpansion.add(tbtnDESPERTAR);
        tbtnDESPERTAR.setText("DESPERTAR");
        tbtnDESPERTAR.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbtnDESPERTARActionPerformed(evt);
            }
        });

        buttonGroupExpansion.add(tbtnINSANIA);
        tbtnINSANIA.setText("INSANIA");
        tbtnINSANIA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbtnINSANIAActionPerformed(evt);
            }
        });

        jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/wizard_images/wizard_page3.jpg"))); // NOI18N

        btnBack2.setMnemonic('a');
        btnBack2.setText("<< Anterior");
        btnBack2.setToolTipText("Paso Anterior");
        btnBack2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBack2ActionPerformed(evt);
            }
        });

        btnNext2.setMnemonic('s');
        btnNext2.setText("Siguiente >>");
        btnNext2.setToolTipText("Paso Siguiente");
        btnNext2.setEnabled(false);
        btnNext2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNext2ActionPerformed(evt);
            }
        });

        btnCancel2.setMnemonic('c');
        btnCancel2.setText("Cancelar");
        btnCancel2.setToolTipText("Cancelar Asistente");
        btnCancel2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancel2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelExpansionLayout = new javax.swing.GroupLayout(panelExpansion);
        panelExpansion.setLayout(panelExpansionLayout);
        panelExpansionLayout.setHorizontalGroup(
            panelExpansionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelExpansionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelExpansionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE)
                    .addGroup(panelExpansionLayout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelExpansionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(panelExpansionLayout.createSequentialGroup()
                                .addComponent(btnBack2, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnNext2)
                                .addGap(18, 18, 18)
                                .addComponent(btnCancel2))
                            .addComponent(tbtnDESPERTAR, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
                            .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbtnINSANIA, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE))))
                .addContainerGap())
        );
        panelExpansionLayout.setVerticalGroup(
            panelExpansionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelExpansionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelExpansionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelExpansionLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tbtnDESPERTAR)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tbtnINSANIA))
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelExpansionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancel2)
                    .addComponent(btnNext2)
                    .addComponent(btnBack2))
                .addContainerGap())
        );

        wizardPanels.add(panelExpansion, "card4");

        jLabel12.setText("Selecciona el Demonio con el que quieras jugar.");

        jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/wizard_images/wizard_page4.jpg"))); // NOI18N

        btnBack3.setMnemonic('a');
        btnBack3.setText("<< Anterior");
        btnBack3.setToolTipText("Paso Anterior");
        btnBack3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBack3ActionPerformed(evt);
            }
        });

        btnFinish.setMnemonic('f');
        btnFinish.setText("Finalizar");
        btnFinish.setToolTipText("Paso Siguiente");
        btnFinish.setEnabled(false);
        btnFinish.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinishActionPerformed(evt);
            }
        });

        btnCancel3.setMnemonic('c');
        btnCancel3.setText("Cancelar");
        btnCancel3.setToolTipText("Cancelar Asistente");
        btnCancel3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancel3ActionPerformed(evt);
            }
        });

        buttonGroupDemon.add(btnDemon1);
        btnDemon1.setText("tbtnDemon1");
        btnDemon1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDemon1ActionPerformed(evt);
            }
        });

        buttonGroupDemon.add(btnDemon2);
        btnDemon2.setText("tbtnDemon2");
        btnDemon2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDemon2ActionPerformed(evt);
            }
        });

        buttonGroupDemon.add(btnDemon3);
        btnDemon3.setText("tbtnDemon");
        btnDemon3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDemon3ActionPerformed(evt);
            }
        });

        txtaDemon.setColumns(20);
        txtaDemon.setEditable(false);
        txtaDemon.setLineWrap(true);
        txtaDemon.setRows(5);
        txtaDemon.setWrapStyleWord(true);
        jScrollPane1.setViewportView(txtaDemon);

        javax.swing.GroupLayout panelDemonLayout = new javax.swing.GroupLayout(panelDemon);
        panelDemon.setLayout(panelDemonLayout);
        panelDemonLayout.setHorizontalGroup(
            panelDemonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDemonLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDemonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDemonLayout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDemonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
                            .addComponent(btnDemon3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
                            .addComponent(btnDemon2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelDemonLayout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(90, 90, 90))
                            .addComponent(btnDemon1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)))
                    .addComponent(jSeparator4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDemonLayout.createSequentialGroup()
                        .addComponent(btnBack3, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnFinish, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnCancel3)))
                .addContainerGap())
        );
        panelDemonLayout.setVerticalGroup(
            panelDemonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDemonLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDemonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDemonLayout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDemon1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDemon2, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDemon3, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelDemonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancel3)
                    .addComponent(btnFinish)
                    .addComponent(btnBack3))
                .addContainerGap())
        );

        wizardPanels.add(panelDemon, "card5");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(wizardPanels, javax.swing.GroupLayout.DEFAULT_SIZE, 620, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(wizardPanels, javax.swing.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE)
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancelActionPerformed

    private void panelExpansionFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_panelExpansionFocusGained
    }//GEN-LAST:event_panelExpansionFocusGained

    private void btnBack1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBack1ActionPerformed
        ((CardLayout) wizardPanels.getLayout()).previous(wizardPanels);
    }//GEN-LAST:event_btnBack1ActionPerformed

    private void btnNext1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNext1ActionPerformed
        ((CardLayout)wizardPanels.getLayout()).next(wizardPanels);    }//GEN-LAST:event_btnNext1ActionPerformed

    private void btnCancel1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancel1ActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancel1ActionPerformed

    private void btnBack2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBack2ActionPerformed
        ((CardLayout) wizardPanels.getLayout()).previous(wizardPanels);
    }//GEN-LAST:event_btnBack2ActionPerformed

    private void btnNext2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNext2ActionPerformed
        if (loadDemons()) {
            ((CardLayout) wizardPanels.getLayout()).next(wizardPanels);
        }
    }//GEN-LAST:event_btnNext2ActionPerformed

    private void btnCancel2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancel2ActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancel2ActionPerformed

    private void btnBack3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBack3ActionPerformed
        ((CardLayout) wizardPanels.getLayout()).previous(wizardPanels);
    }//GEN-LAST:event_btnBack3ActionPerformed

    private void btnFinishActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinishActionPerformed
        Deck newDeck = new Deck(txtDeckName.getText(), demon);
        if (Queries.save(newDeck)) {
            Drecker.addDeckTab(newDeck);
        } else {
            JOptionPane.showMessageDialog(this, "Por un problema con la base de "
                    + "datos, no se pudo\ncrear el nuevo mazo \"" + newDeck.getName()
                    + "\".\nSi el problema persiste intente descargar Drecker"
                    + "nuevamente", "Error de Datos", JOptionPane.ERROR_MESSAGE);
        }

        this.dispose();
    }//GEN-LAST:event_btnFinishActionPerformed

    private void btnCancel3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancel3ActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancel3ActionPerformed

    private void tbtnCaosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbtnCaosActionPerformed
        pathway = Queries.getPathway("Caos");
        txtaPathway.setText(pathway.getDescription());
        enableStep2();
    }//GEN-LAST:event_tbtnCaosActionPerformed

    private void tbtnLocuraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbtnLocuraActionPerformed
        pathway = Queries.getPathway("Locura");
        txtaPathway.setText(pathway.getDescription());
        enableStep2();
    }//GEN-LAST:event_tbtnLocuraActionPerformed

    private void tbtnMuerteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbtnMuerteActionPerformed
        pathway = Queries.getPathway("Muerte");
        txtaPathway.setText(pathway.getDescription());
        enableStep2();
    }//GEN-LAST:event_tbtnMuerteActionPerformed

    private void tbtnPoderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbtnPoderActionPerformed
        pathway = Queries.getPathway("Poder");
        txtaPathway.setText(pathway.getDescription());
        enableStep2();
    }//GEN-LAST:event_tbtnPoderActionPerformed

    private void tbtnDESPERTARActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbtnDESPERTARActionPerformed
        enableStep3();
    }//GEN-LAST:event_tbtnDESPERTARActionPerformed

    private void tbtnINSANIAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbtnINSANIAActionPerformed
        enableStep3();
    }//GEN-LAST:event_tbtnINSANIAActionPerformed

    private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
        if (!Queries.checkName(txtDeckName.getText())) {
            JOptionPane.showMessageDialog(this, "Ya existe un mazo registrado con"
                    + " el nombre \"" + txtDeckName.getText() + "\".", "Error de Datos",
                    JOptionPane.WARNING_MESSAGE);
            txtDeckName.requestFocus();
        } else {
            ((CardLayout) wizardPanels.getLayout()).next(wizardPanels);
        }
}//GEN-LAST:event_btnStartActionPerformed

private void btnDemon1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDemon1ActionPerformed
    demon = (Card) demons.get(0);
    setDemonDescription();
}//GEN-LAST:event_btnDemon1ActionPerformed

private void btnDemon2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDemon2ActionPerformed
    demon = (Card) demons.get(1);
    setDemonDescription();
}//GEN-LAST:event_btnDemon2ActionPerformed

private void btnDemon3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDemon3ActionPerformed
    demon = (Card) demons.get(2);
    setDemonDescription();
}//GEN-LAST:event_btnDemon3ActionPerformed

    private void setDemonDescription() {
        txtaDemon.setText(demon.getFullDescription());
        btnFinish.setEnabled(true);
    }

    private void enableStep2() {
        btnNext1.setEnabled(true);
    }

    private void enableStep3() {
        btnNext2.setEnabled(true);
    }

    private void enableFinish() {
        btnFinish.setEnabled(true);
    }

    private boolean loadDemons() {
        boolean result = true;
        String expansionName;
        if (tbtnDESPERTAR.isSelected()) {
            expansionName = "Despertar";
        } else {
            expansionName = "Insania";
        }
        demons = Queries.getDemons(pathway.getName(), expansionName);
        if (demons == null) {
            JOptionPane.showMessageDialog(this, "Hubo un problema con la base de"
                    + " datos, y no se pudieron cargar los demonios.", "Error de Datos",
                    JOptionPane.ERROR_MESSAGE);
            this.dispose();
        } else if (demons.size() < 1) {
            JOptionPane.showMessageDialog(this, "No hay demonios de "
                    + pathway.getName() + " de la expansión "
                    + expansionName + " en la base de datos.\nPor favor"
                    + " elige otras características.", "Error de Datos",
                    JOptionPane.WARNING_MESSAGE);
            result = false;
        } else {
            btnDemon1.setText(((Card) demons.get(0)).getName());
            btnDemon2.setText(((Card) demons.get(1)).getName());
            btnDemon3.setText(((Card) demons.get(2)).getName());
            btnDemon1.setSelected(false);
            btnDemon2.setSelected(false);
            btnDemon3.setSelected(false);
            txtaDemon.setText("");
        }
        return result;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBack1;
    private javax.swing.JButton btnBack2;
    private javax.swing.JButton btnBack3;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnCancel1;
    private javax.swing.JButton btnCancel2;
    private javax.swing.JButton btnCancel3;
    private javax.swing.JToggleButton btnDemon1;
    private javax.swing.JToggleButton btnDemon2;
    private javax.swing.JToggleButton btnDemon3;
    private javax.swing.JButton btnFinish;
    private javax.swing.JButton btnNext1;
    private javax.swing.JButton btnNext2;
    private javax.swing.JButton btnStart;
    private javax.swing.ButtonGroup buttonGroupDemon;
    private javax.swing.ButtonGroup buttonGroupExpansion;
    private javax.swing.ButtonGroup buttonGroupSenda;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JLabel lblDeckName;
    private javax.swing.JLabel lblStart;
    private javax.swing.JPanel panelDemon;
    private javax.swing.JPanel panelExpansion;
    private javax.swing.JPanel panelSenda;
    private javax.swing.JPanel panelWelcome;
    private javax.swing.JScrollPane scrollPathway;
    private javax.swing.JToggleButton tbtnCaos;
    private javax.swing.JToggleButton tbtnDESPERTAR;
    private javax.swing.JToggleButton tbtnINSANIA;
    private javax.swing.JToggleButton tbtnLocura;
    private javax.swing.JToggleButton tbtnMuerte;
    private javax.swing.JToggleButton tbtnPoder;
    private javax.swing.JTextField txtDeckName;
    private javax.swing.JTextArea txtaDemon;
    private javax.swing.JTextArea txtaPathway;
    private javax.swing.JTextArea txtaWelcome;
    private javax.swing.JPanel wizardPanels;
    // End of variables declaration//GEN-END:variables
}
